"""Main Controller"""
from sample.lib.base import BaseController
from tg import expose, flash
from pylons.i18n import ugettext as _
#from tg import redirect, validate
#from sample.model import DBSession, metadata
#from dbsprockets.dbmechanic.frameworks.tg2 import DBMechanic
#from dbsprockets.saprovider import SAProvider

import pylons

from sample.lymon import Page_1, Page_2

from lymon.tw import Site



class RootController(BaseController):
    #admin = DBMechanic(SAProvider(metadata), '/admin')

    @expose('sample.templates.index')
    
    def index(self, page = 'page1', **kw):
        flash(_("You're running TG2! (change me in root.py)"))
        if page == 'page1':
        	site = Site(document=Page_1())
        	viewPage = "This is Page 1"
        elif page == 'page2':
        	site = Site(document=Page_2())
        	viewPage = "This is Page 2 ( Inherited from page 1 )"
        	
        pylons.c.w.site = site
        
        return dict(page=viewPage)

    @expose('sample.templates.about')
    def about(self):
        return dict(page='about')
